import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ObjCreate } from "../../common/ObjCreate";
import { SCrossCountryInfo } from "../../../../../Message/Game/SCrossCountryInfo";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GTextFormat } from "../../../../common/GTextFormat";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class CrossTaskServerListRender
    
    export  class CrossTaskServerListRender extends CellRenderer
    {
        constructor()
        {
            super();
            this._textFormat = GlobalStyle.textFormat1;
            this.initStyle();
            this.addEventListener(flash.events.MouseEvent.CLICK, this.clickHandler);
            return;
        }

        protected initStyle(): void
        {
            var loc1=new Object /* flash.geom.Rectangle */(2, 2, 56, 15);
            this.setStyle("upSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonNoBorder_overSkin, loc1));
            this.setStyle("downSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_upSkin, loc1));
            this.setStyle("overSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_upSkin, loc1));
            this.setStyle("selectedDownSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_overSkin, loc1));
            this.setStyle("selectedOverSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_overSkin, loc1));
            this.setStyle("selectedUpSkin", GlobalClass.getScaleBitmap(ImagesConst.ButtonGreen_overSkin, loc1));
            this.setStyle("disabledSkin", GlobalClass.getScaleBitmap(ImagesConst.ShortcutBtn_disabledSkin, loc1));
            this.setStyle("textFormat", this._textFormat);
            this.setStyle("disabledTextFormat", this._textFormat);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            var loc2=null;
            if (arg1 == null) 
            {
                loc2 = new Object /* flash.display.Bitmap */();
                this.setStyle("downSkin", loc2);
                this.setStyle("overSkin", loc2);
                this.setStyle("upSkin", loc2);
                this.setStyle("selectedDownSkin", loc2);
                this.setStyle("selectedOverSkin", loc2);
                this.setStyle("selectedUpSkin", loc2);
                this.drawNow();
                return;
            }
            super.data = arg1;
            if (this._txt == null) 
            {
                this._txt = ObjCreate.createGTextField("", 4, 0, 120, 20, this);
            }
            var loc1=arg1 as SCrossCountryInfo;
            this._txt.text = "[" + EntityUtil.getProxyNameByProxyAndServer(loc1.serverKey.proxyId, loc1.serverKey.serverId, "-") + "] " + loc1.money.toString();
            if (EntityUtil.isSameServerByProxyAndServer(loc1.serverKey.proxyId, loc1.serverKey.serverId)) 
            {
                this.enabled = false;
            }
            else 
            {
                this.enabled = true;
            }
            this.drawNow();
            return;
        }

        /* internal  */clickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CrossTaskSelectServer, super.data));
            return;
        }

        /* internal */ /* var */_textFormat: GTextFormat;

        /* internal */ /* var */_txt: GTextFiled;
    }
